package com.ruoyi.work.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.work.mapper.WorkClientMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.work.mapper.WorkMediaFlowMapper;
import com.ruoyi.work.domain.WorkMediaFlow;
import com.ruoyi.work.service.IWorkMediaFlowService;
import com.ruoyi.common.core.text.Convert;

/**
 * 刷量媒体资料Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-01-02
 */
@Service
public class WorkMediaFlowServiceImpl implements IWorkMediaFlowService 
{
    @Autowired
    private WorkMediaFlowMapper workMediaFlowMapper;
    @Autowired
    private WorkClientMapper workClientMapper;

    /**
     * 查询刷量媒体资料
     * 
     * @param mediaId 刷量媒体资料主键
     * @return 刷量媒体资料
     */
    @Override
    public WorkMediaFlow selectWorkMediaFlowByMediaId(Long mediaId)
    {
        return workMediaFlowMapper.selectWorkMediaFlowByMediaId(mediaId);
    }

    /**
     * 查询刷量媒体资料列表
     * 
     * @param workMediaFlow 刷量媒体资料
     * @return 刷量媒体资料
     */
    @Override
    public List<WorkMediaFlow> selectWorkMediaFlowList(WorkMediaFlow workMediaFlow)
    {
        return workMediaFlowMapper.selectWorkMediaFlowList(workMediaFlow);
    }

    /**
     * 新增刷量媒体资料
     * 
     * @param workMediaFlow 刷量媒体资料
     * @return 结果
     */
    @Override
    public int insertWorkMediaFlow(WorkMediaFlow workMediaFlow)
    {
        workMediaFlow.setCreateTime(DateUtils.getNowDate());
        workMediaFlow.setContacts(workClientMapper.selectWorkClientByClientId(workMediaFlow.getContactId()).getClientName());
        return workMediaFlowMapper.insertWorkMediaFlow(workMediaFlow);
    }

    /**
     * 修改刷量媒体资料
     * 
     * @param workMediaFlow 刷量媒体资料
     * @return 结果
     */
    @Override
    public int updateWorkMediaFlow(WorkMediaFlow workMediaFlow)
    {
        workMediaFlow.setUpdateTime(DateUtils.getNowDate());
        return workMediaFlowMapper.updateWorkMediaFlow(workMediaFlow);
    }

    /**
     * 批量删除刷量媒体资料
     * 
     * @param mediaIds 需要删除的刷量媒体资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkMediaFlowByMediaIds(String mediaIds)
    {
        return workMediaFlowMapper.deleteWorkMediaFlowByMediaIds(Convert.toStrArray(mediaIds));
    }

    /**
     * 删除刷量媒体资料信息
     * 
     * @param mediaId 刷量媒体资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkMediaFlowByMediaId(Long mediaId)
    {
        return workMediaFlowMapper.deleteWorkMediaFlowByMediaId(mediaId);
    }
}
